
#include "globals.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "DetectorConstruction.hh"
#include "PhysicsList.hh"
#include "PrimariesGenerator.hh"
#include "G4UIExecutive.hh"
#include "G4VisManager.hh"

#ifdef G4VIS_USE
#include "G4VisExecutive.hh"
#endif

#ifdef G4UI_USE
#include "G4UIExecutive.hh"
#endif
#include <TApplication.h>
#include <TGClient.h>
int main()
{
	G4RunManager* runManager = new G4RunManager;
	DetectorConstruction *detector = new DetectorConstruction(1*m,1*m,1*cm);
	runManager->SetUserInitialization(detector);
	G4VUserPhysicsList *physics = new PhysicsList();
	runManager-> SetUserInitialization(physics);
	G4VUserPrimaryGeneratorAction* gen_action = new PrimariesGenerator(300);
	runManager->SetUserAction(gen_action);

	runManager->Initialize();


	G4UImanager* UI = G4UImanager::GetUIpointer();
	UI->ApplyCommand("/run/verbose 0");
	UI->ApplyCommand("/event/verbose 0");
	UI->ApplyCommand("/tracking/verbose 0");


	G4double Rmin = 20*cm,Rmax=1*m,deltaR=5*cm;
	G4double lScInit = 0.2*cm,lScFinal = 4*cm,deltaLSc = 0.2*cm;
	G4double lAbsInit = 1*m,lAbsFinal = 10*m,deltaLAbs = 1*m;
	G4double R=Rmin,lSc=lScInit,lAbs=lAbsInit;
	G4cout<<R<<" "<<lSc<<" "<<lAbs<<G4endl;
	for(R = Rmin;R<=Rmax;R+=deltaR)
	{
		detector->SetRadius(R);

		for(lSc = lScInit;lSc<=lScFinal;lSc+=deltaLSc)
		{
			for(lAbs = lAbsInit;lAbs<=lAbsFinal;lAbs+=deltaLAbs)
			{
				detector->SetMediumProperties(lAbs,lSc);
				runManager->BeamOn(1);
			}
		}
		G4cout<<R<<" "<<lSc<<" "<<lAbs<<G4endl;
	}
	//G4UIsession * session = new G4UIterminal;
	//session->SessionStart();

	//delete session;
	delete runManager;
	//runManager->BeamOn(100);*/

	return 0;
}

